import { defineStore } from 'pinia'

export const useMapStore = defineStore('map', {
  state: () => ({
    center: [104.06, 30.67],
    zoom: 10,
    terrain: true,
    baseLayer: 'osm',
  }),
  actions: {
    setCenter(center: number[]) {
      this.center = center
    },
    setZoom(zoom: number) {
      this.zoom = zoom
    },
    toggleTerrain() {
      this.terrain = !this.terrain
    },
    setBaseLayer(layer: string) {
      this.baseLayer = layer
    },
  },
})

export const useMonitorStore = defineStore('monitor', {
  state: () => ({
    waterLevel: 0,
    flow: 0,
    rainfall: 0,
    lastUpdate: '',
  }),
  actions: {
    updateData(data: any) {
      this.waterLevel = data.waterLevel
      this.flow = data.flow
      this.rainfall = data.rainfall
      this.lastUpdate = new Date().toISOString()
    },
  },
}) 